﻿#region Usings

using System.Web;
using System.Web.Mvc;
using System.Web.Routing;

#endregion Usings

namespace BK.Web.UI
{
	// Note: For instructions on enabling IIS6 or IIS7 classic mode,
	// visit http://go.microsoft.com/?LinkId=9394801

	public class MvcApplication : HttpApplication
	{
		#region Instance Methods

		protected void Application_Start()
		{
			AreaRegistration.RegisterAllAreas();

			RegisterRoutes(RouteTable.Routes);
			ControllerBuilder.Current.SetControllerFactory(new WindsorControllerFactory());
		}

		#endregion Instance Methods

		#region Class Methods

		public static void RegisterRoutes(RouteCollection routes)
		{
			routes.IgnoreRoute("{resource}.axd/{*pathInfo}");

			//			routes.MapRoute(null,
			//							"", // Only matches the empty URL (i.e. ~/)
			//							new
			//								{
			//									controller = "Payments",
			//									action = "Index",
			//									userId = (int?)null,
			//									page = 1
			//								});

			routes.MapRoute(
				"Paged", // Route name
				"{controller}/{action}/{page}", // URL with parameters
				new { controller = "Home", action = "Index", page = 1 } // Parameter defaults
				);

			routes.MapRoute(null,
							"{controller}/{action}/{userId}/{page}",
							new { controller = "Payments", action = "Index", page = 1 });
		}

		#endregion Class Methods
	}
}